uplus:
	tsx
	clc
	adc $102,x
	sta $102,x
	vmnext_pla


twostore:
	tax
	pla
	sta 0,x
	pla
	sta 1,x
	vmnext_pla

enum TEMP
	NX: .db 0
	NY: .db 0
	PX: .db 0
	PY: .db 0
ende



; hardwired obj size = 16x16 for now


solid_obj_xmove: colon

	semi

solid_obj_ymove: colon
	.dw  vyfetch, or
	nifdo exit
	.dw  vyfetch, drop, zeroless
	mif +then

	+then

	semi

solid_obj_move: colon
	.dw  xfetch, vxfetch, dplus, f2d, lit, NX, store
	.dw  xfetch, vxfetch, dplus, f2d, lit, NY, store
	.dw solid_obj_xmove, solid_obj_ymove
	semi


do_player_movement: colon

	mcallasm andcase
	.dw PAD_LEFT
	mif +then
		.dw twolit,$ffec,vxstore
		semi
	+then

	mcallasm andcase
	.dw PAD_RIGHT
	mif +then
		.dw twolit,$0014,vxstore
		semi
	+then

	mcallasm andcase
	.dw PAD_UP
	mif +then
		.dw twolit,$ffec,vxstore
		semi
	+then

	mcallasm andcase
	.dw PAD_DOWN
	mif +then
		.dw twolit,$0014,vxstore
		semi
	+then

	.dw zero,dup,twodup, vxstore, vystore

	semi


load_overworld_screen: colon
	.dw lit, OVERWORLD_POS, fetch, load_screen
	semi

do_player_world: colon
	.dw xfetch,dropdup
	.dw lit,$0f,greater
	mif +then
		.dw droplit, 1, lit, OVERWORLD_POS, plusstore
		.dw zero, dup, xstore
		.dw load_overworld_screen
		semi
	+then
	.dw lit,$00,less
	mif +then
		.dw lit, $ff, lit, OVERWORLD_POS, plusstore
		.dw twolit, $0f00, xstore
		.dw load_overworld_screen
		semi
	+then

	.dw yfetch,dropdup
	.dw lit,$0b,greater
	mif +then
		.dw droplit, 4, lit, OVERWORLD_POS, plusstore
		.dw zero, dup, ystore
		.dw load_overworld_screen
		semi
	+then
	.dw lit,$00,less
	mif +then
		.dw lit, $fc, lit, OVERWORLD_POS, plusstore
		.dw twolit, $0b00, ystore
		.dw load_overworld_screen
		semi
	+then
	semi

doplayer:	colon
	.dw zero, padstate
	.dw do_player_movement, drop ;solid_obj_move do_player_world
	.dw screenxy, twolit, ms_player_idle_right, metaspr
	.dw oplus                    ; go to next object
	semi